<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html,body{
            height: 100%;
            background: #f8f8f8;
        }
        input,textarea {
            outline: none;
        }
        #inp {
            width: 90%;
            margin:10px auto;
            display: block;
            background: #fff;
            height: 140px;
            border-radius: 5px;
            padding: 5px;
        }
    </style>
</head>
<body>
    <textarea id="inp"></textarea>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
    apiready = function(){
        var field = api.pageParam.field;
        var name = api.pageParam.name;
        var holder = api.pageParam.holder;
        var default_value = api.pageParam.value;
        $('#inp').attr('placeholder',holder);
        if(default_value) {
            $('#inp').val(default_value);
        }
        api.addEventListener({
            name: 'confirmEditGoodsEvent'
        }, function(ret, err) {
            if (ret) {
                var value = $('#inp').val();
                if(!value) {
                    api.toast({
                        msg: '请先填入'+name,
                        location:'middle'
                    });
                    return;
                }

                api.sendEvent({
                    name: 'addGoodsEvent',
                    extra: {
                        edit: field, 
                        value: value,
                        desc: value
                    }
                });
                api.closeWin();
            }
        });

    };
</script>
</html>